package com.sloera.nowcoder;

import java.util.Locale;
import java.util.Scanner;

/**
 * class com.sloera.nowcoder
 * user sloera
 * date 2022/2/23
 */
public class HJ2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            final String source = in.nextLine();
            final String alphabet = in.nextLine();
            int a = count(source.toLowerCase(Locale.ROOT), alphabet.toLowerCase(Locale.ROOT));
            System.out.println(a);
        }
    }

    private static int count(String source, String alphabet) {
        final char c = alphabet.charAt(0);
        int count = 0;
        for (int i = 0; i < source.length(); i++) {
            if (source.charAt(i) == c) {
                count++;
            }
        }
        return count;
    }
}